package sr.myserver.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import sr.myserver.commons.DateUtils;

/**
 * Mybatis自动填充
 *
 * @author sirui
 */
@Component
public class MybatisPlusMetaConfig implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("crtTs", DateUtils.getDateTime(), metaObject);
        this.setFieldValByName("updTs", DateUtils.getDateTime(), metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updTs", DateUtils.getDateTime(), metaObject);
    }
}
